 <template>
    <div class="index-page">
        <!-- 顶部按钮 -->
<el-tabs v-model="activeName" >
    <el-tab-pane label="待结算" name="first">
    	<div class="but1">
			<router-link to="/home">
				<el-button type="warning" size="small" class="add btn" style='margin-right: 10px;' icon="el-icon-menu">首页</el-button>
			</router-link> 
		</div>
		<!-- 模糊搜索条件 -->
		<div class="search">
			<el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss" @click='gd'>更多</el-button>
            <el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss1" @click='gd1'>更多</el-button>
            <div class="search-item">
				<span>分组</span>
				<el-select v-model="vfz" placeholder="请选择分组" class="code-search" @change="search">
						<el-option label="主教考勤" value="1"></el-option>
						<el-option label="助教考勤" value="2"></el-option>
				</el-select>
			</div>
			<el-button type="primary" size="small" style="border-radius:13px;" class="add btn" :loading="searchLoading" @click="search" icon="el-icon-search"></el-button>
       		 
		</div>
		
		<div class="search1" v-if='aa'>
            <div class="search-item">
                <span>上课时间</span>
                <el-date-picker  v-model="vbtime" :editable="false"  type="date" class="code-search" placeholder="开始日期" @keyup.enter.native="search">  </el-date-picker>
                <span>-</span>
                <el-date-picker  v-model="vetime" :editable="false"  type="date" class="code-search" placeholder="结束日期" @keyup.enter.native="search">  </el-date-picker>
       		</div>
       		<div class="search-item">
				<el-select v-model="vlsid" class="code-search" placeholder="请选择老师">
					<el-option :label="v.zwm" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
            </div>
        </div>
		<!-- 数据表格展示区域 -->
		<el-table 
			:data="dataList" 
			border 
			stripe 
			size="small" 
			align="center" 
			class="admin-table" 
			@select="checkSelect" 
			@select-all="checkall">
			<!--<el-table-column type="selection" width="55"></el-table-column>-->
			 <el-table-column label="老师名称" width="100" align="center">
				<template scope="scope">
					<el-button size="small" type="text" style="color:#1F2D3D;text-decoration:underline;background: #BEDBDF; " @click="componentsShow('lsxq',scope)">{{scope.row.zwm}}</el-button>
				</template>
			</el-table-column>
			<div slot='empty'>
				<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
				<span style="vertical-align: middle;">暂时还没有内容哦!</span>
			</div>
			<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
				<template scope="scope">
					<div slot="reference" :style="tableCellControl(scope)">
						{{ scope.row[scope.column.property] }}
					</div>
				</template>
			</el-table-column>
			<el-table-column label="操作" width="100px" v-if='false' align="center">
				<template scope="scope">
					<!-- v-if="scope.row.qx == 'Y'"--> 
					<el-button size="mini" type="success" @click="componentsShow('info',scope)">详情</el-button> 
				</template>
			</el-table-column>
		</el-table>
		<!-- 分页查询区域 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination>
    </el-tab-pane>
    <el-tab-pane label="结算日志" name="second">
    	<div class="but1">
			<router-link to="/home">
				<el-button type="warning" size="small" class="add btn" style='margin-right: 10px;' icon="el-icon-menu">首页</el-button>
			</router-link> 
		</div>
		<div class="search">
			<el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss" @click='gd'>更多</el-button>
            <el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss1" @click='gd1'>更多</el-button>
            <div class="search-item">
				<span>分组</span>
				<el-select v-model="vfz" placeholder="请选择分组" class="code-search" @change="search">
						<el-option label="全部"  value=""></el-option>
						<el-option label="主教考勤" value="1"></el-option>
						<el-option label="助教考勤" value="2"></el-option>
				</el-select>
			</div>
			<el-button type="primary" size="small" style="border-radius:13px;" class="add btn" :loading="searchLoading" @click="search1" icon="el-icon-search"></el-button>
		</div>
		<div class="search1" v-if='aa'>
            <div class="search-item">
                <span>结算时间</span>
                <el-date-picker  v-model="vbtime" :editable="false"  type="date" class="code-search" placeholder="开始日期" @keyup.enter.native="search">  </el-date-picker>
                <span>-</span>
                <el-date-picker  v-model="vetime" :editable="false"  type="date" class="code-search" placeholder="结束日期" @keyup.enter.native="search">  </el-date-picker>
       		</div>
       		<div class="search-item">
				<el-select v-model="vlsid" class="code-search" placeholder="请选择老师">
					<el-option :label="v.zwm" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
            </div>
        </div>
		<el-table 
			:data="dataList1" 
			border 
			stripe 
			size="small" 
			align="center" 
			class="admin-table" 
			@select="checkSelect" 
			@select-all="checkall">
			 <el-table-column label="老师名称" width="100" align="center">
				<template scope="scope">
					<el-button size="small" type="text" style="color:#1F2D3D;text-decoration:underline;background: #BEDBDF; " @click="componentsShow('lsxq',scope)">{{scope.row.zwm}}</el-button>
				</template>
			</el-table-column>
			<div slot='empty'>
				<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
				<span style="vertical-align: middle;">暂时还没有内容哦!</span>
			</div>
			<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList1" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
				<template scope="scope">
					<div slot="reference" :style="tableCellControl(scope)">
						{{ scope.row[scope.column.property] }}
					</div>
				</template>
			</el-table-column>
			<el-table-column label="操作" width="100px" align="center">
				<template scope="scope">
					<el-button size="mini" type="success" @click="componentsShow('info',scope)">详情</el-button> 
				</template>
			</el-table-column>
			</el-table>
			<!-- 分页查询区域 -->
        <el-pagination
            @size-change="handleSizeChange1"
            @current-change="handleCurrentChange1"
            :current-page.sync="pageindex1"
            :page-sizes="pagesizes1"
            :page-size="pagesize1"
            :layout="layout"
            :total="total1"
            class="class-page">
        </el-pagination>
    </el-tab-pane>
  </el-tabs>
        

        <!-- 各个组件显示区域 -->
        <!-- 添加组件 -->
        <AddComponent v-if="portComponents.add.toggle"  @close="componentsHide"  :params="portComponents.add.params"></AddComponent>
        <!-- 编辑组件 -->
        <EditComponent v-if="portComponents.edit.toggle"  @close="componentsHide"  :params="portComponents.edit.params"></EditComponent>
		
		<InfoComponent v-if="portComponents.info.toggle" @close="componentsHide" :params="portComponents.info.params"></InfoComponent>
        <!-- 单独删除组件 -->
        <DeleteComponent v-if="portComponents.singleDelete.toggle"  @close="componentsHide"  :data="portComponents.singleDelete.data"></DeleteComponent>

        <LsxqComponent v-if="portComponents.lsxq.toggle" @close="componentsHide" :params="portComponents.lsxq.params"></LsxqComponent>
        <!-- 批量删除组件 -->
        <DeleteComponent v-if="portComponents.multipleDelete.toggle"  @close="componentsHide"  :data="portComponents.multipleDelete.data"></DeleteComponent>

        <JsxqComponent v-if="portComponents.jsxq.toggle" @close="componentsHide" :params="portComponents.jsxq.params"></JsxqComponent>

        <!-- 子路由显示区域 -->
        <router-view class="port-view"></router-view>
    </div>
</template>
<script>
    import { mapState } from 'vuex'
    import qs from 'qs'
    import AddComponent from './add'
    import LsxqComponent from '../personManage/lsxq'
    import JsxqComponent from './jsxq/list'
    import InfoComponent from './info'
    import EditComponent from './edit'
    import DeleteComponent from './del'
    export default {
        components: {
            JsxqComponent,
            DeleteComponent,
            InfoComponent,
            LsxqComponent,
            AddComponent,
            EditComponent
        },
        data () {
            return {
            	aa:false,
			    ss:true,
			    ss1:false,
            	activeName:'first',
            	vlsid:'',
            	vfz:'1',
            	vbtime:'',
            	vetime:'',
            	comboxlist:[],
//              type: '',
                vkeyword: '',
                /*组件区域*/
                portComponents: {
                    singleDelete: {
                        type: 'singleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'single',
                            title: '此操作将删除该班级, 是否继续?'
                        }
                    },
                    multipleDelete: {
                        type: 'multipleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'multiple',
                            title: '此操作将删除您选中的班级, 是否继续?'
                        }
                    },
                    add: {
                        type: 'add',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    info: {
                        type: 'info',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    edit: {
                        type: 'edit',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                     jsxq: {
                        type: 'jsxq',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    lsxq: {
                        type: 'lsxq',
                        toggle: false,
                        params: '',
                        data: {}
                    }
                },
                multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据
                dataList1: [],  //表格数据
                
                /*
                    prop :  接口参数名
                    label : 接口中文名
                    hide : 是否隐藏这一列   0是隐藏  1是显示
                    align : 这一列对齐顺序 ： left,right,center
                    headerAlign : 这一列表头对齐方式 ： left,right,center
                    formatter: function (row, column) {}
                */
                portTitleList1: [
                {
                        prop:'id',
                        label:'id',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                {
                        prop:'lsid',
                        label:'lsid',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'jslx',
                        label:'分组类型',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'zsc',
                        label:'总时长',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'zcs',
                        label:'总次数',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'je',
                        label:'金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'jj',
                        label:'奖金',
                        hide:1	,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'jsr',
                        label:'结算人',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },

                    {
                        prop:'jssj',
                        label:'结算时间',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                ],
                
                portTitleList: [
                {
                        prop:'lsid',
                        label:'lsid',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'fzlx',
                        label:'分组类型',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'bjmc',
                        label:'考勤班级',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'kqsj',
                        label:'考勤时间',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'sc',
                        label:'时长',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'cnt',
                        label:'次数',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'rs',
                        label:'人数',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },

                    {
                        prop:'js',
                        label:'角色',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                ],


                /*动画加载*/
                isLoading: false,//动画加载
                searchLoading: false,//搜索按钮触发按钮动画

                /*模糊搜索条件*/
                inputbjmc:'' , //  班级名称,


                /*分页属性设置*/
                layout: 'total, sizes, prev, pager, next, jumper',//组件布局
                pageindex: 1,//当前分页页码
                pagesizes: [12, 24, 36, 72],//显示个数的选择器选项
                pagesize: 12,//每页显示条目数
                total: 0,//总条数
                
                /*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex1: 1, //当前分页页码
				pagesizes1: [12, 24, 36, 72], //显示个数的选择器选项
				pagesize1: 12, //每页显示条目数
				total1: 0, //总条数


                dropDownData:'', //
            }
        },
        created () {
            //加载页面时调用
            this.$store.dispatch('changeTitle','老师课时结算');//修改title
            this.$store.dispatch('changeRouterIndex', '/admin/teacherjs');//修改路由
            this.search();//分页获取默认数据
            this.search1();//分页获取默认数据
            this.getcomboxlist();

        },//加载页面时
        methods: {
        	tableCellControl(scope) { //表格单元格控制CSS样式
//            if (scope.row.qfje>=0 && scope.column.property == "qfje") {
//                return {
//                    color:"red",
//                }
//            }
			},
        	gd(){
        		this.aa=true;
        		this.ss=false;
        		this.ss1=true;
        	},
        	gd1(){
        		this.aa=false;
        		this.ss=true;
        		this.ss1=false;
        	},
          getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ls/mc', params2)
					.then(res => {
						console.log(res,'iiiiiii')
						let data = res.data.data;
						let list = data;
						this.comboxlist = list;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
            search () {//查询搜索触发事件
            	var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
	          var time2 = this.$.getLocalTimeNo0(Date.parse(this.vetime));
            	var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
             	        btime:time1,
             	        etime: time2,
             	        fz: this.vfz,
                        lsmc: this.vlsid,
                        yhid:logininfo.id,
                        xxid:logininfo.xxid,
                        pageindex: this.pageindex,
                        pagesize: this.pagesize
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/lsksdjs',  params2 )
                 .then(res => {
                    console.log('qqqq',res)
                    let data = res.data.data;
                    let list = data.list;
                    this.total = data.totalPage;
                    this.dataList = list;
                    this.searchLoading = false;
                 }).catch(res => {
					 console.log(res)
                  this.searchLoading = false;
				})
            },
            handleSizeChange (val) {//每页显示条数触发事件
                this.pagesize = val;
                this.pageindex = 1;
                this.search();
            },
            handleCurrentChange (val) {//分页触发事件
                this.search();
            },
            checkSelect (selection, row) {//点击单选select触发事件
                console.log(selection, row)
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
            },
            checkall (selection) {//点击全选select触发事件
                // console.log(selection)
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                // console.log(strID.join(","))
                this.multipleDelNum = strID.join(",");
                // console.log(strID)
            },
            
            search1 () {//查询搜索触发事件
            	var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
	          var time2 = this.$.getLocalTimeNo0(Date.parse(this.vetime));
            	var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
             	        btime:time1,
             	        etime: time2,
             	        fz: this.vfz,
                        lsmc: this.vlsid,
                        yhid:logininfo.id,
                        xxid:logininfo.xxid,
                        pageindex: this.pageindex1,
                        pagesize: this.pagesize1
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/lsksjsrz',  params2 )
                 .then(res => {
//                  console.log('qqqq2222222222',res)
                    let data = res.data.data;
                    let list = data.list;
                    this.total1 = data.totalPage;
                    this.dataList1 = list;
                    this.searchLoading = false;
                 }).catch(res => {
					 console.log(res)
                  this.searchLoading = false;
				})
            },
            handleSizeChange1 (val) {//每页显示条数触发事件
                this.pagesize1 = val;
                this.pageindex1 = 1;
                this.search1();
            },
            handleCurrentChange1 (val) {//分页触发事件
                this.search1();
            },
            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
//              console.log(type,data)
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {

                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;

                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id

                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;

                        }else if(this.portComponents[i].type == 'test'){
                            this.portComponents[i].data.distinction  = "test";

                        }else if(this.portComponents[i].type == 'score'){
                            this.portComponents[i].data.distinction  = "score";

                        }else{
                            return;
                        }
                        return;
                    }
                }

            },
            componentsHide (setting) { //关闭组件
                console.log(setting)
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;

                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
            }
        },
        computed: {
            multipleDeleteDisabled () {
                console.log(this.multipleDelNum)
                if (this.multipleDelNum) {
                    return false;
                }else{
                    return true
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .index-page {
        font-size:12px;
        position: relative;

        .btn {
            height: 30px;
            padding:0 10px;
            margin-left: 0;
        }
 .but1{
      width: 30%;
			height: 50px;
			float: left;
			line-height: 50px;
    }
    .search{
      width: 70%;
      height: 50px;
      line-height: 50px;
      float: right;
      text-align: right;
    }
    .search1{
			width: 50%;
			height: 50px;
			float: right;
			line-height: 50px;
			margin-right: 0px;
			text-align: right;
		}
        .classInfo:hover {
            color:#4094c7;
            cursor:pointer;
            text-decoration: underline;
        }

        .code-search {
            max-width: 130px;
            min-width: 100px;
            text-align: center;
            height: 50px;
            /*line-height: 50px;*/
            font-size: 12px;
        }

        .change-time{
            width: 480px;
            display: inline-block;
        }

        .class-page {
            text-align: left;
            margin-top:10px;
        }

        .search-item {
            display: inline-block;
        }

        h2{
            line-height: 40px;
        }

    }
</style>
